<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">


<head>
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8"/>
    <title>协同开发文件管理系统-登录</title>
    <meta name="keywords" content="协同开发文件管理系统"/>
    <meta name="description" content="协同开发文件管理系统"/>
    <meta name="author" content="AdminDesigns"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <!-- Admin Forms CSS -->
    <link rel="stylesheet" type="text/css" href=""
          th:href="@{/resources/assets/admin-tools/admin-forms/css/admin-forms.css}"/>

    <!-- Theme CSS -->
    <link rel="stylesheet" type="text/css" href="" th:href="@{/resources/assets/skin/default_skin/css/theme.css}"/>

    <!-- Favicon -->
    <link rel="shortcut icon" href="" th:href="@{/resources/assets/img/favicon.ico}"/>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
</head>
<style>

    .threed {
        text-align: center;
        margin-left: auto;
        margin-right: auto;
        color: #fafafa;
        letter-spacing: 0;
        text-shadow: 0px 1px 0px #999, 0px 2px 0px #888, 0px 3px 0px #777, 0px 4px 0px #666, 0px 5px 0px #555, 0px 6px 0px #444, 0px 7px 0px #333, 0px 8px 7px #001135
    }
</style>

<body class="external-page external-alt sb-l-c sb-r-c">
<!-- Start: Main -->
<div id="main" class="animated fadeIn">

    <!-- Start: Content-Wrapper -->
    <section id="content_wrapper">
        <!-- Begin: Content -->
        <section id="content">

            <div class="admin-form theme-info mw500" style="margin-top: 3%;" id="login">

                <!-- Login Logo -->
                <div class="row table-layout">
                    <a href="" th:href="@{/admin/login}">
                        <img src="/resources/assets/img/logos/logo.png" th:src="@{/resources/assets/img/logos/logo.png}"
                             class="w400"/>
                    </a>
                </div>


                <!-- Login Panel/Form -->
                <div><span style='color: red;' id="login-resmsg"></span></div>

                <div class="panel mt30 mb25">

                    <form method="post" action="" id="contact">
                        <div class="panel-body bg-light p25 pb15">
                            <!-- Username Input -->
                            <div class="section">
                                <label class="field-label text-muted fs18 mb10">用户</label>
                                <label class="field prepend-icon">
                                    <input type="text" name="userName" id="userName" class="gui-input"
                                           placeholder="输入用户"/>
                                    <label class="field-icon">
                                        <i class="fa fa-user"></i>
                                    </label>
                                </label>
                            </div>

                            <!-- Password Input -->
                            <div class="section">
                                <label for="pwd" class="field-label text-muted fs18 mb10">密码</label>
                                <label for="pwd" class="field prepend-icon">
                                    <input type="password" name="pwd" id="pwd" class="gui-input"
                                           placeholder="输入密码"/>
                                    <label for="pwd" class="field-icon">
                                        <i class="fa fa-lock"></i>
                                    </label>
                                </label>
                            </div>
                        </div>

                        <div class="panel-footer clearfix">
                            <button type="button" onclick="loginCheck();" class="button btn-primary mr10 pull-right">
                                登录
                            </button>
                            <label class="switch ib switch-primary mt10">
                                <input type="checkbox" name="isRemember" id="isRemember"/>
                                <label for="isRemember" data-on="是" data-off="否"></label>
                                <span>记住</span>
                            </label>
                        </div>

                    </form>
                </div>
            </div>

        </section>
        <!-- End: Content -->

    </section>
    <!-- End: Content-Wrapper -->

</div>
<!-- End: Main -->


<!-- BEGIN: PAGE SCRIPTS -->

<!-- jQuery -->
<script src="vendor/jquery/jquery-1.11.1.min.js" th:src="@{/resources/vendor/jquery/jquery-1.11.1.min.js}"></script>
<script src="vendor/jquery/jquery_ui/jquery-ui.min.js"
        th:src="@{/resources/vendor/jquery/jquery_ui/jquery-ui.min.js}"></script>

<!-- Theme Javascript -->
<script src="assets/js/utility/utility.js" th:src="@{/resources/assets/js/utility/utility.js}"></script>
<script src="assets/js/main.js" th:src="@{/resources/assets/js/main.js}"></script>

<!-- 提示 PNotify -->
<script th:src="@{/resources/vendor/plugins/pnotify/pnotify.js}"></script>

<!-- md5 -->
<script th:src="@{/resources/js/md5.js}"/>

<!-- Page Javascript -->
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    function getCookie(name) {
        var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg))
            return unescape(arr[2]);
        else
            return null;
    }
    function setCookie(name,value) {
        var Days = 30;
        var exp = new Date();
        exp.setTime(exp.getTime() + Days*24*60*60*1000);
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
    }


    $(function () {
        $(document).keydown(function (event) {
            if (event.keyCode == 13) {
                loginCheck();
            }
        });

        var isRem = getCookie("checkRemember");
        if(isRem != null && isRem == "y"){
            $("#isRemember").attr("checked","checked");
        }
    })

    var url = /*[[@{/admin/signIn}]]*/  "/admin/signIn";

    function loginCheck() {
        var account = $("#userName").val();
        var password = $("#pwd").val();
        var isRemember = $("input[name='isRemember']").is(':checked');
        if (account == null || account == "" || password == null || password == "") {
            new PNotify({
                title: '登入失败',
                text: "用户名或密码不能为空",
                type: 'danger',
                delay: 1000
            });
            return;
        }
        if($("#isRemember").prop("checked") == true){
            setCookie("checkRemember", "y");
        } else {
            setCookie("checkRemember", "n");
        }
        $.ajax({
            type: "post",
            url: url,
            data: {'account': account, 'password': hex_md5(hex_md5(password)), 'isRemember': isRemember},
            dataType: "json",
            success: function (resultData) {
                var code = resultData.code;
                if (code == "1") {
                    window.location.href = /*[[@{/admin/dashboard}]]*/"/admin/dashboard";
                } else {
                    $("#pwd").val("");
                    new PNotify({
                        title: '登入失败',
                        text: resultData.msg,
                        type: 'danger',
                        delay: 1000
                    });
                    return;
                }
            }
        });
    }
    /*]]>*/
</script>

<!-- END: PAGE SCRIPTS -->

</body>

</html>
